﻿#region

using System;
using System.Collections.Generic;
using Minion.Win.Client.Models;

#endregion

namespace Minion.Win.Client.Helper
{
    public static class Utilities
    {
        public static T FindObject<T>(IList<Location> locs, Guid idToFind) where T : class, new()
        {
            foreach (var location in App.CurrentLocationDetails)
            {
                if (location.Id == idToFind) return location as T;
                foreach (var locationItem in location.LocationItems)
                {
                    if (locationItem.Id == idToFind)
                        return locationItem as T;
                    foreach (var locationItemDetail in locationItem.LocationItemDetails)
                    {
                        if (locationItemDetail.Id == idToFind) return locationItemDetail as T;
                    }
                }
            }
            return null;
        }
    }
}